<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: AppVars.cfc 1195 2007-07-18 05:05:59Z pfarrell $

Notes:
This plugin is autowired by ColdSpring.
--->
<cfcomponent
	displayname="AppVars"
	extends="MachII.framework.Plugin"
	output="false"
	hint="Plugin to ensure all the application-wide objects and variables needed are set as properties in the property manager.">

	<!---
	INITIALIZATION / CONFIGURATIONS
	--->
	<cffunction name="configure" access="public" returntype="void" output="false"
		hint="Configures the plugin.">
		<cfset setProperty("resourceBundleService", getResourceBundleService()) />
		<cfset getProperty("resourceBundleService").getResourceBundle().loadResourceBundle() />
		<cfset setProperty("udfs", getUdfs()) />
		<cfset setProperty("archiveList", getEntryService().getArchiveList(getProperty("numMonthsOfArchives"))) />
	</cffunction>

	<cffunction name="setResourceBundleService" access="public" output="false" returntype="void"
		hint="Dependency: injected">
		<cfargument name="resourceBundleService" type="org.machblog.i18n.ResourceBundleService" 
				required="true" />
		<cfset variables.resourceBundleService = arguments.resourceBundleService />
	</cffunction>
	<cffunction name="getResourceBundleService" access="private" output="false" 
				returntype="org.machblog.i18n.ResourceBundleService">
		<cfreturn variables.resourceBundleService />
	</cffunction>
	
	<cffunction name="setUdfs" access="public" output="false" returntype="void" 
			hint="Dependency: injected">
		<cfargument name="udfs" type="org.machblog.utils.udfs" required="true" />
		<cfset variables.udfs = arguments.udfs />
	</cffunction>
	<cffunction name="getUdfs" access="private" output="false" returntype="org.machblog.utils.udfs">
		<cfreturn variables.udfs />
	</cffunction>
	
	<cffunction name="setEntryService" access="public" output="false" returntype="void" 
			hint="Dependency: injected">
		<cfargument name="entryService" type="org.machblog.entry.EntryService" required="true" />
		<cfset variables.entryService = arguments.entryService />
	</cffunction>
	<cffunction name="getEntryService" access="public" output="false" returntype="org.machblog.entry.EntryService">
		<cfreturn variables.entryService />
	</cffunction>

	<!---
	PUBLIC FUNCTIONS - PLUGIN POINTS
	--->
	<cffunction name="preProcess" access="public" returntype="void" output="false">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />

		<cfset var firstEvent = arguments.eventContext.getNextEvent() />

		<!--- Set the URL event name --->
		<cfset firstEvent.setArg("mainEvent", firstEvent.getName()) />
	</cffunction>

</cfcomponent>